#!/usr/bin/perl -w
use warnings;
use strict;
use DBI;
require('config.pl');
require('function.pl');

my $db_conn = DBI->connect("DBI:mysql:database=58_spider;host=$ENV{'db_host'}", $ENV{'db_user'}, $ENV{'db_password'});
$db_conn->do('set names utf8');
my $sql = 'select phone_num, count(*) from spider_data group by phone_num';
my $request = $db_conn->prepare($sql);
my $result = $request->execute();
while (my ($phone_num, $count) = $request->fetchrow_array) {
	if ($count > 5) {
		$db_conn->do("replace into agent values('$phone_num')");
	}
}
